#include <iostream>
#include <vector>
#include <string>

bool is_prime(int n) {
    if (n % 2 == 0) {
        return n == 2;
    }
    int d = 3;
    while (d * d <= n && n % d != 0) {
        d += 2;
    }
    return d * d > n;
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::vector<std::string> text;
    std::string number = "";

    size_t pos = 0;
    std::string token;
    while ((pos = input.find(' ')) != std::string::npos) {
        token = input.substr(0, pos);
        text.push_back(token);
        input.erase(0, pos + 1);
    }
    text.push_back(input);

    for (const auto& i : text) {
        if (i == "zero") {
            number += '0';
        }
        if (i == "one") {
            number += '1';
        }
        if (i == "two") {
            number += '2';
        }
        if (i == "three") {
            number += '3';
        }
        if (i == "four") {
            number += '4';
        }
        if (i == "five") {
            number += '5';
        }
        if (i == "six") {
            number += '6';
        }
        if (i == "seven") {
            number += '7';
        }
        if (i == "eight") {
            number += '8';
        }
        if (i == "nine") {
            number += '9';
        }
    }

    int num = std::stoi(number);

    if (99 < num && num < 1000) {
        int tmp = std::abs(num - 2);
        int res = 2;
        int k = 3;
        while (true) {
            if (is_prime(k)) {
                int t = std::abs(num - k);
                if (t < tmp) {
                    tmp = t;
                    res = k;
                } else {
                    std::cout << res << std::endl;
                    break;
                }
            }
            k += 2;
        }
    } else {
        std::cout << "Wrong input" << std::endl;
    }

    return 0;
}
